package com.qf.flash.mvp.presenter;

import com.qf.flash.http.HttpManager;
import com.qf.flash.model.HotListBean;
import com.qf.flash.mvp.contract.HotlistContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.sharedpreferences.SavePermanentSharePrefs;
import com.qf.flashlib.sharedpreferences.SharePrefConstants;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

public class HotListBeanPresenter extends BasePresenter<HotlistContract.View> implements HotlistContract.Presenter {
    @Override
    public void getHotListDatas(String type, int pageNo, int pageSize) {
        String areaId = SavePermanentSharePrefs.getInstance().getDataString(SharePrefConstants.AREA_ID);
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_HOT_PLAY_LIST(areaId,type, pageNo, pageSize)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<HotListBean>>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<List<HotListBean>> listResponse) {
                        mRootView.setHotListBeans(listResponse.getData(),listResponse.getTotalPage());
                    }
                })
        );
    }
}
